﻿/*
 * ============ [ 废土 ] ============
 *
 * [ 维护者 ]  argoran@gmail.com
 * [  状态  ]  原型
 *
 * ============ [ 注释 ] ============
 *
 * 存储用户帐户信息的类
 *
 * ==================================
 */

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace LastLand.Data.Connection
{
    public class CUserAccount
    {
        private String username_ = null;       //用户名
        private String password_ = null;       //密码的md5码
        private Int32 connectionBinding_ = -1; //账户绑定的客户端连接

        private Int32 activeCharacterIndex_ = -1;                      //当前角色序号
        private List<Int32> deadCharacterList_ = new List<Int32>();    //死亡角色序号列表

        //构造函数
        public CUserAccount(String _username, String _password, Int32 _activeCharacterIndex, List<Int32> _deadCharacterList)
        {
            username_ = _username;
            password_ = _password;
            //index_ = _index;
            activeCharacterIndex_ = _activeCharacterIndex;

            //参数_deadCharacterList为null时，表示用户从未使角色死亡过
            if (_deadCharacterList != null)
            {
                for (Int32 i = 0; i < _deadCharacterList.Count; i++)
                {
                    deadCharacterList_.Add(_deadCharacterList[i]);
                }
            }
        }

        //用户创建了一个新的角色
        public void CreateCharacter(Int32 _activeCharacterIndex)
        {
            if (activeCharacterIndex_ != -1)
                deadCharacterList_.Add(activeCharacterIndex_);
            activeCharacterIndex_ = _activeCharacterIndex;
        }

        //返回用户名
        public String Username
        {
            get { return username_; }
        }

        //返回密码的md5码
        public String Password
        {
            get { return password_; }
        }

        //返回或修改账户绑定的客户端连接
        public Int32 ConnectionBinding
        {
            get { return connectionBinding_; }
            set { connectionBinding_ = value; }
        }

        //返回当前角色序号
        public Int32 ActiveCharacterIndex
        {
            get { return activeCharacterIndex_; }
        }

        //返回死亡角色序号列表的枚举器
        public List<Int32> DeadCharacterList
        {
            get { return deadCharacterList_; }
        }

        //返回账户是否已经与客户端连接绑定
        public Boolean IsBinded()
        {
            return connectionBinding_ != -1;
        }
    }
}
